package com.webbei.Backstage.action;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.wabbei.fenxiao.action.MyTaobaoUtil;
import com.webbei.Backstage.service.BackstateSer;
import com.webbei.pojo.Orders;

public class SyncOrders {
	private BackstateSer bao;
	private String startTime;
	private Integer num;
	private Integer day;
	public String execute(){
		System.out.println("StartTime:"+startTime);
		SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd");
		Date s;
		try {
			s = formatDate.parse(startTime);
			Date e = new Date((long)(s.getTime()+24*60*60*1000*day));
			SimpleDateFormat formatDate2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String start = formatDate2.format(s);
			String end = formatDate2.format(e);
			System.out.println(start+","+end);
			List<Orders> oList = new MyTaobaoUtil().getFullOrderList(start, end);
			num = bao.syncOrders(oList);
		} catch (ParseException e1) {
			e1.printStackTrace();
		}
		return "success";
	}

	public void setBao(BackstateSer bao) {
		this.bao = bao;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public Integer getNum() {
		return num;
	}

	public void setNum(Integer num) {
		this.num = num;
	}

	public Integer getDay() {
		return day;
	}

	public void setDay(Integer day) {
		this.day = day;
	}

}
